import java.sql.SQLOutput;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-08-27
 * Time: 17:32
 */
public class threadDemo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //throw new RuntimeException(e);
                    //e.printStackTrace();

                }
            }
            System.out.println("thread线程已经结束");
        });
        thread.start();
        Thread.sleep(3000);
        System.out.println("控制thread线程结束");
        thread.interrupt();
    }
}
